import axios from '../../plugins/axios.js'
import formatTime from '../../utils/formatTime.js'
const state = {
	detail:[]
}

const actions = {
	detail: async ({state,commit},{_id,collectionName}={})=>{
		// let res = await axios.get(`/news/${colelctionName}/${_id}`)
		let {data} = await axios.get(`/news/${collectionName}/${_id}`)
	    // commit('detail',res.data)
	    commit('detail',data)
	}
}

const mutations ={
	detail:(state,payload)=>{
		state.detail = payload
	}
}

const getters = {
	cptTime:()=>{
		return formatTime(state.detail.time)
	}
}

export default {
	namespaced:true,
	state,actions,mutations,getters
}